load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "ptstorage",
    srcs = [
        "sql.go",
        "storage.go",
        "storage_with_database.go",
    ],
    embed = [":ptstorage_go_proto"],
    importpath = "github.com/cockroachdb/cockroach/pkg/kv/kvserver/protectedts/ptstorage",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/clusterversion",
        "//pkg/kv/kvserver/protectedts",
        "//pkg/kv/kvserver/protectedts/ptpb",
        "//pkg/settings/cluster",
        "//pkg/sql/isql",
        "//pkg/sql/sem/tree",
        "//pkg/sql/sessiondata",
        "//pkg/util/hlc",
        "//pkg/util/log",
        "//pkg/util/protoutil",
        "//pkg/util/uuid",
        "@com_github_cockroachdb_errors//:errors",
    ],
)

go_test(
    name = "ptstorage_test",
    size = "large",
    srcs = [
        "main_test.go",
        "storage_test.go",
        "validate_test.go",
    ],
    embed = [":ptstorage"],
    shard_count = 16,
    deps = [
        "//pkg/base",
        "//pkg/keys",
        "//pkg/kv",
        "//pkg/kv/kvserver/protectedts",
        "//pkg/kv/kvserver/protectedts/ptpb",
        "//pkg/roachpb",
        "//pkg/security/securityassets",
        "//pkg/security/securitytest",
        "//pkg/server",
        "//pkg/settings/cluster",
        "//pkg/spanconfig",
        "//pkg/sql",
        "//pkg/sql/catalog",
        "//pkg/sql/catalog/colinfo",
        "//pkg/sql/catalog/descpb",
        "//pkg/sql/isql",
        "//pkg/sql/parser/statements",
        "//pkg/sql/sem/tree",
        "//pkg/sql/sessiondata",
        "//pkg/testutils",
        "//pkg/testutils/serverutils",
        "//pkg/testutils/skip",
        "//pkg/testutils/testcluster",
        "//pkg/util/hlc",
        "//pkg/util/leaktest",
        "//pkg/util/log",
        "//pkg/util/log/severity",
        "//pkg/util/protoutil",
        "//pkg/util/randutil",
        "//pkg/util/uuid",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_stretchr_testify//require",
    ],
)

proto_library(
    name = "ptstorage_proto",
    srcs = ["storage.proto"],
    strip_import_prefix = "/pkg",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/roachpb:roachpb_proto",
        "@com_github_gogo_protobuf//gogoproto:gogo_proto",
    ],
)

go_proto_library(
    name = "ptstorage_go_proto",
    compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"],
    importpath = "github.com/cockroachdb/cockroach/pkg/kv/kvserver/protectedts/ptstorage",
    proto = ":ptstorage_proto",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/roachpb",
        "@com_github_gogo_protobuf//gogoproto",
    ],
)
